﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Text;
using V5_Common;
using V5_BLL;

namespace V5_EShop._Class.Data {
    public class V5SQLHelper {
        private static readonly V5SQLHelper m_Instance = new V5SQLHelper();
        /// <summary>
        /// 
        /// </summary>
        public static V5SQLHelper Instance {
            get { return m_Instance; }
        }
        private BLLSQL bll = new BLLSQL();
        private HtmlString _Pager;
        /// <summary>
        /// 分页数据
        /// </summary>
        public HtmlString Pager {
            get { return _Pager; }
            set { _Pager = value; }
        }
        /// <summary>
        /// 查询数据库记录
        /// </summary>
        public DataTable Query_By(string what, string from, string where, string orderby, int limit) {
            return bll.Query_By(what, from, where, orderby, limit);
        }
        /// <summary>
        /// 查询分页数据库记录
        /// </summary>
        public DataTable Query_Pager(string what, string from, string where, string orderby, int limit, int pageIndex, string indexName, string UrlFormat) {
            DataTable drc = null;
            int RecordCount = 0;
            drc = bll.Query_Pager(what, from, where, orderby, limit, pageIndex, indexName, ref RecordCount);
            PagerHelper pager = new PagerHelper();
            pager.RecordCount = RecordCount;
            pager.CurrentPageIndex = pageIndex;
            pager.PageSize = int.Parse("0" + limit);
            pager.PageUrlFormat = UrlFormat.Replace("@pageid@", "{0}");
            this.Pager = new HtmlString(pager.Display());
            return drc;
        }
    }
}